local skel = fk.CreateSkill {
  name = "lb_zero__shuangxin",
  max_branches_use_time = function(self, player)
    local room = Fk:currentRoom()
    local list = {}
    for _, to in ipairs(room.players) do
      list[tostring(to.id)] = { [Player.HistoryGame] = 1 }
    end
    return list
  end
}

local LB_U = require "packages.lb_kill_utility.utility"

Fk:loadTranslationTable {
  ["lb_zero__shuangxin"] = "霜心",
  --[":lb_zero__shuangxin"] = "游戏开始时，你<a href='#freeze_href'><font color='red'>冻结体力值</font></a>。出牌阶段限一次，若你未冻结体力值，你可以冻结你与一名其他角色的体力值。",
  --11.7
  [":lb_zero__shuangxin"] = "游戏开始时，你<a href='#freeze_href'><font color='red'>冻结体力值</font></a>。每名角色限一次，出牌阶段，你可以冻结一名角色的体力值。",

  ["#lb_zero__shuangxin"] = "霜心：你可以冻结一名角色的体力值",

  ["@[skill_players]lb_zero__shuangxin"] = "霜心",

  ["$lb_zero__shuangxin1"] = "哼，别眨眼睛哦。",
  ["$lb_zero__shuangxin2"] = "哼，轮到我了。",
}

skel:addEffect("active", {
  anim_type = "control",
  prompt = "#lb_zero__shuangxin",
  can_use = function (self, player)
    return table.find(Fk:currentRoom().alive_players, function (to)
      return skel:withinBranchTimesLimit(player, tostring(to.id), Player.HistoryGame) and not LB_U.isfreezeHp(to)
    end)
    --return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0 and not LB_U.isfreezeHp(player)
  end,
  card_num = 0,
  target_filter = function (self, player, to_select, selected, selected_cards, card, extra_data)
    return #selected == 0 and not LB_U.isfreezeHp(to_select)
  end,
  feasible = function (self, player, selected, selected_cards, card)
    return #selected == 1
  end,
  on_use = function (self, room, skillUseEvent)
    skillUseEvent.from:addSkillBranchUseHistory(skel.name, tostring(skillUseEvent.tos[1].id))
    --LB_U.freezeHp(skillUseEvent.from)
    LB_U.freezeHp(skillUseEvent.tos[1])
  end,
})

skel:addEffect(fk.GameStart, {
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name)
  end,
  on_use = function(self, event, target, player, data)
    LB_U.freezeHp(player)
  end,
})

skel:addAcquireEffect(function(self, player, is_start)
  player.room:setPlayerMark(player, "@[skill_players]lb_zero__shuangxin",
    { name = skel.name, scope = Player.HistoryGame, players = table.map(player.room.players, Util.IdMapper) })
end)

skel:addLoseEffect(function(self, player, is_death)
  player.room:setPlayerMark(player, "@[skill_players]lb_zero__shuangxin", 0)
end)

return skel